package com.itheima;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

public class Demo6 {
    public static void main(String[] args) {
        Map<String, Integer> map = new HashMap<>();
        map.put("张三", 85);
        map.put("李四", 80);
        map.put("王五", 90);
        map.put("赵六", 95);
        map.put("田七", 70);

        Function<Map<String, Integer>, ArrayList<Integer>> fun1 = m -> {
            ArrayList<Integer> list = new ArrayList<>();
            list.addAll(m.values());
            return list;
        };
        Function<ArrayList<Integer>, Integer> fun2 = a -> {
            int count = 0;
            for (Integer in : a) {
                count += in;
            }
            return count / a.size();
        };

        ArrayList<Integer> scoreList = fun1.apply(map);

        int avg = fun2.apply(scoreList);
        System.out.println(avg);

    }

}
